#!/bin/bash
# Startup script for backend container

echo "Starting Meeting Room Booking System..."

# Wait for database to be ready
echo "Waiting for database to be ready..."
while ! pg_isready -h db -U postgres > /dev/null 2>&1; do
    sleep 1
done
echo "Database is ready!"

# Run database setup
echo "Running database setup..."
python setup_db.py

# Start the FastAPI application
echo "Starting FastAPI application..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000
